package day5;

/**
 * @author oldliu
 * @since 1.0
 */
public class Company {
    private String name;
    private String address;
    private String tel;
    private String scope;//经营范围

    Employee[] employees=new Employee[10];
    private int employeeCount=0;//员工人数统计

    public Company(String name, String address, String tel, String scope) {
        this.name = name;
        this.address = address;
        this.tel = tel;
        this.scope = scope;
    }
    public boolean hire(Employee e){
        for (int i = 0; i <employees.length ; i++) {
            if(employees[i]==null){
                employees[i]=e;
                return true;
            }
        }
        //满了
        return false;
    }
    public boolean hire(String id,String name,double salary){
        for (int i = 0; i <employees.length ; i++) {
            if(employees[i]==null){
                employees[i]=new Employee();//?
                employees[i].setId(id);
                employees[i].setName(name);
                employees[i].setSalary(salary);
                return true;
            }
        }
        //满了
        return false;
    }
    public boolean fire(String id){
        for (int i = 0; i <employees.length ; i++) {
            if(employees[i]==null){
               return false;
            }
            if(employees[i].getId().equals(id)){
                employees[i]=null;//移动
                for(int j=i;j<employees.length-1;i++){
                    employees[j]=employees[j+1];
                }
                employees[employees.length-1]=null;
                return true;//开除成功了
            }
        }
        return false;
    }
    public void show(){
        ///////
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public int getEmployeeCount() {
        return employeeCount;
    }

    public void setEmployeeCount(int employeeCount) {
        this.employeeCount = employeeCount;
    }
}
